home *** CD-ROM | disk | FTP | other *** search
- // LF2 Engine
- // (C) 2002-3 7FX
- //---------------------------------------------------------------------------
- // Simple font effect with diffuse color only
- //---------------------------------------------------------------------------
- #include "common.fxh"
- //---------------------------------------------------------------------------
- // Common parameters
- // Desc
- string desc : Description = "Shader pro texty, textura a konstantni barva, blenduje se na pozadi.";
- // Requirements
- string req : Requirements = "Diffuse";
- // vertex format needed for all techniques
- string vf : VertexFormat = "POSITION | FONTMAP"; // 129 (for export)
- //---------------------------------------------------------------------------
- // WVP matrix
- const matrix cMtxWVP : WorldViewProjection;
- // Diffuse font color, default white
- const float4 cDiffuse : DIFFUSE = {1.0f, 1.0f, 1.0f, 1.0f};
- // Matrices for fixed function technique
- const matrix cMtxW : World;
- // Sampler filters
- DECLARE_TEX_SAMPLER_VALUES;
- //---------------------------------------------------------------------------
- // Font texture
- texture fonttex : FONTMAP;
- //---------------------------------------------------------------------------
- // Sampler for font texture
- sampler font_sampler = sampler_state
- {
- Texture = <fonttex>;
- SET_TEX_SAMPLER_FILTERS;
- AddressU = CLAMP;
- AddressV = CLAMP;
- };
- //---------------------------------------------------------------------------
- // programs
- struct VS_OUTPUT
- {
- float4 Position : POSITION;
- float2 FontMapCoord : TEXCOORD0;
- };
-
- // vertex shader
- VS_OUTPUT VS(float4 Position : POSITION, float2 FontMapCoord : TEXCOORD0)
- {
- VS_OUTPUT Out = (VS_OUTPUT)0;
- Out.Position = mul(Position, cMtxWVP);
- Out.FontMapCoord = FontMapCoord;
- return Out;
- }
-
- // pixel shader
- float4 PS(VS_OUTPUT In) : COLOR
- {
- return cDiffuse * tex2D(font_sampler, In.FontMapCoord);
- }
-
- //---------------------------------------------------------------------------
- technique vs11_ps11
- <
- // technique streams
- string stream1 = "POSITION | FONTMAP";
- >
- {
- pass p0
- <
- // pass stream mapping
- string streammap = "stream1";
- >
- {
- AlphaRef = 0x08;
- VertexShader = compile vs_1_1 VS();
- PixelShader = compile ps_1_1 PS();
- }
- }
- //---------------------------------------------------------------------------
- technique vs11_ps0
- <
- string stream1 = "POSITION | FONTMAP";
- >
- {
- pass p0
- <
- string streammap = "stream1";
- >
- {
- AlphaRef = 0x08;
-
- TextureFactor = <cDiffuse>;
-
- VertexShader = compile vs_1_1 VS();
-
- Sampler[0] = <font_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = Texture;
- ColorArg2[0] = TFactor;
- AlphaOp[0] = Modulate;
- AlphaArg1[0] = Texture;
- AlphaArg2[0] = TFactor;
- }
- }
- //---------------------------------------------------------------------------
- technique vs0_ps0
- <
- string stream1 = "POSITION | FONTMAP";
- >
- {
- pass p0
- <
- string streammap = "stream1";
- >
- {
- AlphaRef = 0x08;
-
- // matrices
- WorldTransform[0] = <cMtxW>;
-
- TextureFactor = <cDiffuse>;
-
- Sampler[0] = <font_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = Texture;
- ColorArg2[0] = TFactor;
- AlphaOp[0] = Modulate;
- AlphaArg1[0] = Texture;
- AlphaArg2[0] = TFactor;
- }
- }
- //---------------------------------------------------------------------------
-
-